package ibmetp.mis.controller.user;

import ibmetp.mis.common.Constants;
import ibmetp.mis.common.Message;
import ibmetp.mis.service.UserService;
import ibmetp.mis.serviceImpl.UserServiceImpl;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

/**
 *用户进入部门
 */
public class UserInDeptServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
    public UserInDeptServlet() {
        super();
    }

	
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("Calling UserInDeptServlet..");
		//用户Id数组
		String userIds=request.getParameter("userIds");
		Long deptId=Long.valueOf(request.getParameter("deptId"));
		System.out.println(userIds);
		System.out.println(deptId);
		
		UserService us=new UserServiceImpl();
		String result=us.selectUserIntoDept(userIds, deptId);
		//如果有返回消息，则将消息发回页面
		if(result!=null){			
			response.setCharacterEncoding(Constants.ENCODING_UTF8);
			response.getWriter().print(JSONObject.fromObject(new Message(result)));
		}
	}

}
